package org.vectrics.skill.struts;

import org.apache.log4j.Logger;
import org.vectrics.SystemException;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.skill.SkillException;
import org.vectrics.skill.SkillRatingSet;
import org.vectrics.skill.UserEvaluation;

public class UserSkillSummaryTag extends ShowSkillsTagAbstract {

	private static final long serialVersionUID = 4717497787283143211L;

	private transient static Logger log = Logger.getLogger(UserSkillSummaryTag.class);
	private String evaluationId = null;

	protected SkillRatingSet getSkillRatingSet() throws SkillException {
		SkillRatingSet set = null;
		if (evaluationId == null) {
			throw new SystemException("'evaluationId' was not set before rendering");
		}
		log.debug("Skill summary, eval id = " + evaluationId);
		if (evaluationId == null) {
			set = null;
		} else {
			UserEvaluation eval = RecruitServiceLocator.getSkillProvider().findEvaluationById(new Long(evaluationId));
			set = RecruitServiceLocator.getSkillProvider().findUserSkillSet(eval);
		}
/*		
		RemoteUserProvider userMgr = new RemoteUserProvider();
		Person person = null;
		try {
			person = userMgr.findPersonById(new Long(id));
		}
		catch (DataException de) {
			log.error("DataException finding user: " + id);
			throw new SkillException("DataException finding user: " + id);
		}
		*/
		return(set);
	}
	
	protected boolean getShowSkillDetails() {
		return(true);
	}
	
	/**
	 * @return Returns the evalId.
	 */
	public String getEvaluationId() {
		return evaluationId;
	}

	/**
	 * @param evalId The evalId to set.
	 */
	public void setEvaluationId(String evalId) {
		this.evaluationId = evalId;
	}

}
